package com.xd.auth.api.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xd.common.base.BaseModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
    * 用户存储token数据
 * @author huboxin
 */
@ApiModel(value="OauthAccessToken")
@Data
@TableName(value = "oauth_access_token")
public class OauthAccessToken  implements Serializable {
    private static final long serialVersionUID = -1779015103832126151L;
    /**
     * client_id与scope通过MD5加密生成的
     */
    @TableId(value = "authentication_id", type = IdType.INPUT)
    @ApiModelProperty(value="client_id与scope通过MD5加密生成的")
    private String authenticationId;

    /**
     * access_token的值通过MD5加密后存储的
     */
    @TableField(value = "token_id")
    @ApiModelProperty(value="access_token的值通过MD5加密后存储的")
    private String tokenId;

    /**
     * OAuth2AccessToken.java对象序列化后的二进制数据
     */
    @TableField(value = "token")
    @ApiModelProperty(value="OAuth2AccessToken.java对象序列化后的二进制数据")
    private byte[] token;

    /**
     * 登录时的用户名,
     */
    @TableField(value = "user_name")
    @ApiModelProperty(value="登录时的用户名,")
    private String userName;

    @TableField(value = "client_id")
    @ApiModelProperty(value="")
    private String clientId;

    /**
     * 存储将OAuth2Authentication.java对象序列化后的二进制数据
     */
    @TableField(value = "authentication")
    @ApiModelProperty(value="存储将OAuth2Authentication.java对象序列化后的二进制数据")
    private byte[] authentication;

    /**
     * refresh_token的值通过MD5加密后存储的
     */
    @TableField(value = "refresh_token")
    @ApiModelProperty(value="refresh_token的值通过MD5加密后存储的")
    private String refreshToken;

    public static final String COL_AUTHENTICATION_ID = "authentication_id";

    public static final String COL_TOKEN_ID = "token_id";

    public static final String COL_TOKEN = "token";

    public static final String COL_USER_NAME = "user_name";

    public static final String COL_CLIENT_ID = "client_id";

    public static final String COL_AUTHENTICATION = "authentication";

    public static final String COL_REFRESH_TOKEN = "refresh_token";
}
